package com.example.demo.common;

import lombok.Data;

@Data
public class AjaxResult {
    private Integer code;
    private String message;
    private Object data;

    public static AjaxResult success(String message,Object data) {
        AjaxResult result = new AjaxResult();
        result.setCode(200);
        result.setData(data);
        result.setMessage("");
        return result;
    }
    public static AjaxResult success(Object data) {
        AjaxResult result = new AjaxResult();
        result.setCode(200);
        result.setData(data);
        return result;
    }
    public static AjaxResult success(Integer code,String message,Object data) {
        AjaxResult result = new AjaxResult();
        result.setCode(200);
        result.setData(data);
        result.setMessage("");
        return result;
    }
    public static AjaxResult success(Integer code,Object data) {
        AjaxResult result = new AjaxResult();
        result.setCode(code);
        result.setData(data);
        return result;
    }
    public static AjaxResult fail(Integer code,String message,Object data) {
        AjaxResult result = new AjaxResult();
        result.setCode(-1);
        result.setData(data);
        result.setMessage(message);
        return result;
    }
    public static AjaxResult fail(Integer code,String message) {
        AjaxResult result = new AjaxResult();
        result.setCode(-1);

        result.setMessage(message);
        return result;
    }
}
